<?php
//命名空间
namespace Shop\Controller;
//使用命名空间 引入空间里面的类
use Think\Controller;

class BaseController extends Controller {
	
	public  function  __construct()
	{
		parent::__construct();
		
		
		

		define('IS_LOGIN', session('?member'));
		
		
		//菜单
		$topcateArray=M('category')->where('pid=0')->select();//菜单分类
		$subcateArray=M('category')->where('pid>0')->select();
		foreach ($topcateArray as $topkey=>$topvalue)
		{
			foreach($subcateArray as $subkey=>$subvalue)
			{
				if($topvalue['id']==$subvalue['pid'])
				{
					$topcateArray[$topkey]['subcateArray'][]=$subvalue;
				}
			}
		}
		$userinfo=session("userinfo");
		if(!$userinfo)
		{
			$this->assign("is_login",true);
		}
		else{
			$this->assign("is_login",false);
		}
		$this->assign("menuArray",$topcateArray);
		
	}
	
   
	/*
	 * 视图加载
	 */
	public function  view($fhtml)
	{
		$this->display("Public/header");
		$this->display($fhtml);
		$this->display("Public/footer");
	}
	

}